package com.huawei.account.entity.response;

import com.huawei.account.config.Constants;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ApiResponse<T> {
    private int code;
    private String message;
    private T data;

    public static <T> ApiResponse<T> success(T data) {
        return new ApiResponse<>(Constants.SUCCESS, Constants.SUCCESS_MSG, data);
    }

    public static <T> ApiResponse<T> success(String message, T data) {
        return new ApiResponse<>(Constants.SUCCESS, message, data);
    }

    public static <T> ApiResponse<T> error() {
        return new ApiResponse<>(Constants.ERROR, Constants.ERROR_MSG, null);
    }

    public static <T> ApiResponse<T> error(String message) {
        return new ApiResponse<>(Constants.ERROR, message, null);
    }

    public static <T> ApiResponse<T> error(int code, String message) {
        return new ApiResponse<>(code, message, null);
    }
}
